package com.example.android09_sharedpreference;

import android.os.Bundle;
import android.app.Activity;
import android.content.SharedPreferences;
import android.view.Menu;
import android.widget.TextView;

public class SubActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.activity_sub);
		
		TextView tv = new TextView(this);
		setContentView(tv);
		
		SharedPreferences pref = getSharedPreferences("record", MODE_PRIVATE);
		// 2nd param is Default value
		String txt = pref.getString("text","nothing saved");
		
		tv.setText(txt);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_sub, menu);
		return true;
	}

}
